35
Easy2Siksha
(b) Differentiate write() and writeline() functions.
Ans:(b). Once upon a time in a land of computers, there were two friendly little helpers who
lived in the world of programming: write() and writeline(). They were both great at helping
programmers save and display information, but they each had their own unique ways of
doing things. Let's take a journey into their world to understand what makes them special,
and how they differ from each other!
The Beginning: Who Are Write() and Writeline()?
Before we dive into their differences, let’s meet these two helpers:
1. write() is like a quiet, thoughtful helper. It doesn’t speak much; it just writes
whatever you tell it to, and it does so without adding anything extra. When you give
write() some information to save, it simply writes that information exactly as you’ve
told it—no extra space, no new lines, just pure, simple writing.
2. writeline(), on the other hand, is a bit more expressive. This helper writes your
information just like write(), but after doing so, it adds a special “new line” at the
end. Imagine writeline() as someone who writes something and then adds a little
period to finish it off, creating a neat separation between each piece of information.
Now, let’s explore the differences between write() and writeline() in more detail, just like
we would in a fun story!
Chapter 1: The Tale of Write()
Once upon a time, write() lived in a world where precision and control were important.
Programmers, who were always in a hurry, loved write() because it allowed them to be very
specific about how things were written.
Imagine you’re writing a letter. You want to write three sentences, but you don’t want the
computer to move to the next line after each one. You want it all to appear on the same
line, just like writing a long sentence without pressing "Enter" after each one.
This is exactly what write() does. If you tell write() to write “Hello” and then “world,” it will
print them side by side, without any extra spaces or new lines.
Python